package lookas.track;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class GPSPosition implements Comparable<GPSPosition>{

    protected Date  date;
    protected Point position;

    public Point getPosition(){
        return position;
    }

    public void setPosition(Point position){
        this.position = position;
    }

    public Date getDate(){
        return date;
    }

    public void setTime(Date time){
        this.date = time;
    }

    protected GPSPosition(){}

    public GPSPosition(Date time, Point point){
        this.position = point;
        this.date = time;
    }

    @Override
    public String toString(){
        DateFormat df = DateFormat.getDateTimeInstance();
        return df.format(date) + " (" + position + ")";
    }

    public String toXML(){
        String ret;
        ret = String.format("<point date=\"%s\">", new SimpleDateFormat(
            "yyyy-MM-dd'T'HH:mm:ss").format(this.getDate()));
        ret += position.toXML();
        ret += "</point>";
        return ret;
    }

    public int compareTo(GPSPosition o){
        return this.getDate().compareTo(o.getDate());
    }
}
